package com.ruoyi.jhc.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jhc.domain.JhcQtgswf;
import com.ruoyi.jhc.service.IJhcQtgswfService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 气体外发录入Controller
 * 
 * @author ruoyi
 * @date 2023-03-04
 */
@RestController
@RequestMapping("/jhc/qtgswf")
public class JhcQtgswfController extends BaseController
{
    @Autowired
    private IJhcQtgswfService jhcQtgswfService;

    /**
     * 查询气体外发录入列表
     */
    @PreAuthorize("@ss.hasPermi('jhc:qtgswf:list')")
    @GetMapping("/list")
    public TableDataInfo list(JhcQtgswf jhcQtgswf)
    {
        startPage();
        List<JhcQtgswf> list = jhcQtgswfService.selectJhcQtgswfList(jhcQtgswf);
        return getDataTable(list);
    }

    /**
     * 导出气体外发录入列表
     */
    @PreAuthorize("@ss.hasPermi('jhc:qtgswf:export')")
    @Log(title = "气体外发录入", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JhcQtgswf jhcQtgswf)
    {
        List<JhcQtgswf> list = jhcQtgswfService.selectJhcQtgswfList(jhcQtgswf);
        ExcelUtil<JhcQtgswf> util = new ExcelUtil<JhcQtgswf>(JhcQtgswf.class);
        util.exportExcel(response, list, "气体外发录入数据");
    }

    /**
     * 获取气体外发录入详细信息
     */
    @PreAuthorize("@ss.hasPermi('jhc:qtgswf:query')")
    @GetMapping(value = "/{cDate}")
    public AjaxResult getInfo(@PathVariable("cDate") String cDate)
    {
        return AjaxResult.success(jhcQtgswfService.selectJhcQtgswfByCDate(cDate));
    }

    /**
     * 新增气体外发录入
     */
    @PreAuthorize("@ss.hasPermi('jhc:qtgswf:add')")
    @Log(title = "气体外发录入", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JhcQtgswf jhcQtgswf)
    {
        return toAjax(jhcQtgswfService.insertJhcQtgswf(jhcQtgswf));
    }

    /**
     * 修改气体外发录入
     */
    @PreAuthorize("@ss.hasPermi('jhc:qtgswf:edit')")
    @Log(title = "气体外发录入", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JhcQtgswf jhcQtgswf)
    {
        return toAjax(jhcQtgswfService.updateJhcQtgswf(jhcQtgswf));
    }

    /**
     * 删除气体外发录入
     */
    @PreAuthorize("@ss.hasPermi('jhc:qtgswf:remove')")
    @Log(title = "气体外发录入", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cDates}")
    public AjaxResult remove(@PathVariable String[] cDates)
    {
        return toAjax(jhcQtgswfService.deleteJhcQtgswfByCDates(cDates));
    }
}
